package com.plattysoft.leonids.initializers;

import com.plattysoft.leonids.Particle;

import java.security.SecureRandom;

public class SpeeddByComponentsInitializer implements ParticleInitializer {

    private float mMinSpeedX;
    private float mMaxSpeedX;
    private float mMinSpeedY;
    private float mMaxSpeedY;

    public SpeeddByComponentsInitializer(float speedMinX, float speedMaxX, float speedMinY, float speedMaxY) {
        mMinSpeedX = speedMinX;
        mMaxSpeedX = speedMaxX;
        mMinSpeedY = speedMinY;
        mMaxSpeedY = speedMaxY;
    }

    @Override
    public void initParticle(Particle p, SecureRandom r) {
        p.mSpeedX = r.nextFloat() * (mMaxSpeedX - mMinSpeedX) + mMinSpeedX;
        p.mSpeedY = r.nextFloat() * (mMaxSpeedY - mMinSpeedY) + mMinSpeedY;
    }
}
